<template>
  <div class="red-envelope-wrapper">
    <div v-if="!received" class="red-envelope" @click="openRedEnvelope">
      <div class="red-envelope-cover">
        <span class="icon">🎉</span>
        <p>点击领取红包</p>
      </div>
    </div>
    
    <div v-if="received" class="red-envelope-content">
      <p>恭喜你！领取了 {{ redEnvelopeAmount }} 元红包</p>
	  <router-link to="/pages/mine/mine">
      <button @click="closeRedEnvelope" class="close-btn">关闭</button>
	  </router-link>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      received: false, // 是否已领取红包
      redEnvelopeAmount: 0, // 红包金额
    };
  },
  methods: {
    // 点击领取红包
    openRedEnvelope() {
      if (this.received) {
        return; // 已领取，不能重复领取
      }
      
      // 随机生成红包金额
      this.redEnvelopeAmount = (Math.random() * 100 + 1).toFixed(2); // 1到100元
      this.received = true; // 设置为已领取
    },
    
    // 关闭红包显示
    closeRedEnvelope() {
      this.received = false; // 关闭红包
    }
  }
};
</script>
this.$router.replace('/pages/mine/mine"')
<style scoped>
.red-envelope-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  flex-direction: column;
}

.red-envelope {
  background-color: #FF4C4C;
  color: white;
  width: 90%;
  height: 90%;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.red-envelope-cover {
  text-align: center;
}

.icon {
  font-size: 50px;
}

.red-envelope-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.close-btn {
  background-color: #FF4C4C;
  color: white;
  padding: 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
</style>
